//rankingByDate  按日期下钻js
function backDateDetail(occurdate,eD,sD,dateFlag){
	if(""==eD||''==eD||undefined==eD||null==eD){
		eD=getDate(0);
	}
	//年
	var currYear=occurdate.toString().split("-")[0];
	var endYear=eD.toString().split("-")[0];
	var startYear=sD.toString().split("-")[0];
	var strY="-12-31";
	var strX="-01-01~";
	if('year'==dateFlag){
		if(endYear==currYear){
			return endYear+strX+eD;
		}
		if((parseToDecimalInt(endYear)-parseToDecimalInt(currYear))>0){
			if(startYear==currYear){
				return sD+"~"+currYear+strY;
			}
			return currYear+strX+currYear+strY;
		}
		
	}
	//月
	if('month'==dateFlag){
		var m1=occurdate.toString().split("-")[1];
		var sM=sD.toString().split("-")[1];
		var eM=eD.toString().split("-")[1];
		var monthComm=(occurdate.toString().split("-")[0])+"-"+(occurdate.toString().split("-")[1]);//年-月
		if(parseToDecimalInt(eM)==parseToDecimalInt(m1)){
			return monthComm+"-01~"+eD;
		}
		if((parseToDecimalInt(eM)-parseToDecimalInt(m1))>0){
			var m1D="";
			switch (parseToDecimalInt(m1)) {
			case 1:
				m1D="-31";
				break;
			case 2:
				m1D="-28";
				break;
			case 3:
				m1D="-31";
				break;
			case 4:
				m1D="-30";
				break;
			case 5:
				m1D="-31";
				break;
			case 6:
				m1D="-30";
				break;
			case 7:
				m1D="-31";
				break;
			case 8:
				m1D="-31";
				break;
			case 9:
				m1D="-30";
				break;
			case 10:
				m1D="-31";
				break;
			case 11:
				m1D="-30";
				break;
			case 12:
				m1D="-31";
				break;
			default:
				break;
			}
			if(sM==m1){
				//sM  28 ,30 ,31
				return sD+"~"+monthComm+m1D;
						
			}
			return monthComm+"-01~"+monthComm+m1D;
		}
	}
	
	//日
	if('day'==dateFlag){
		return occurdate+"";//sD+"~"+eD;
	}
}

// Convert a int string to int. Removing first leading zero.
function parseToDecimalInt(intStr){
	var str = intStr;
	if(intStr.length>1 && intStr.match(/^0/)){
		str = intStr.substr(1);
	}
	return parseInt(str);
}

//取的今天，昨天，上周 等时间 dates  为0今天 
function getDate(dates){
    var dd = new Date();
    dd.setDate(dd.getDate()+dates);
 
    var y = dd.getFullYear();
    var m = dd.getMonth()+1;
    var d = dd.getDate();
   return y+"-"+m+"-"+d;
}

